import {
	post,
	get,
	iget,
	ipost,
	noLogin,
	noLoginPost,
	writeoffpost,
	notoastpost
} from './http';
import {
	BASEURL
} from './http.js';
import {
	showLoading,
	hideLoading
} from '@/utils/toast.js';

//获取四个品牌详情接口
export const getExhibitionListApi = data => get('/appletCbe/getExhibitionList', data);
//获取原产地
export const getOriginListApi = data => get('/appletCbe/getOriginList', data);
//获取品类
export const getFirstCategoryListApi = data => get('/appletCbe/getFirstCategoryList', data);

//美妆列表
export const getExhibitionPageApi = data => noLoginPost('/appletCbe/getExhibitionPage', data);
//品牌详情
export const getBrandInfoApi = data => noLoginPost('/appletCbe/getBrandInfo', data);
//预览产品列表
export const previewProductListApi = data => noLoginPost('/info/previewProduct', data);

//根据品牌获取品牌分类
export const getProductTypeListApi = data => noLoginPost('/appletCbe/getProductTypeList', data);
//根据品牌分类获取产品
export const getProductListByTypeApi = data => noLoginPost('/appletCbe/getProductListByType', data);


//工厂产品详情
export const getGoodInfoByIdApi = data => iget('/info/preview', data);
//品牌详情
export const getBrandInfoByIdApi = data => iget('/info/preview', data);
//工厂详情
export const getFactoryInfoByIdApi = data => iget('/info/preview', data);
//生态服务详情
export const getSupplierInfoByIdApi = data => iget('/info/preview', data);

//全部产品
export const getAllProductListApi = data => noLoginPost('/appletCbe/search/pageAllProductList', data);
//全部产地
export const getProductOriginListApi = data => get('/appletCbe/search/getOriginList', data);

//(小程序接口)
//品牌列表 
export const getBrandListApi = data => noLoginPost('/info/Applet/BrandList', data);

//品牌品类
export const getBrandCategoryListApi = data => get('/info/getBrandCategoryList', data);
//品牌二级品类
export const getBrandChildCategoryListApi = data => iget('/info/getBrandCategoryTwoList', data);
//根据类型获取分类
export const getBrandCategoryListByTypeApi = data => iget('/appletCbe/search/getBrandCategoryList', data);
//根据产品一级分类获取二级分类
export const getChildBrandCategoryListByPidApi = data => iget('/appletCbe/search/getChildCategoryList', data);

//品牌原产地
export const getProductingOriginListApi = data => get('/info/getProducingAreaList', data);
//品牌原产地
export const getChannelListApi = data => get('/info/getChannelList', data);
//工厂分类
export const getFactoryCategoryListApi = data => get('/info/getFactoryCategoryList', data);
//工厂二级分类
export const getFactoryCategoryTwoListApi = data => iget('/info/getFactoryCategoryTwoList', data);
//工厂产地
export const getAreaCodeListApi = data => get('/info/getAreaCodeList', data);
//工厂列表
export const getFactoryListApi = data => noLoginPost('/info/Applet/FactoryList', data);
//生态服务分类
export const getProviderCategoryListApi = data => get('/info/getProviderCategoryList', data);
//生态服务列表
export const getAppletProviderListApi = data => noLoginPost('/info/Applet/ProviderList', data);





//获取广告
//	 1 首页banner图 2 快捷入口 3 品牌banner图 4 品牌置顶图 5 品牌瀑布流 6 生态服务banner图 7 生态服务置顶图 8 工厂banner图 9 工厂置顶图 10 中部banner图
//	 11 产品banner图  12 产品置顶图  13 中部banner图 15 直播广告 16 资讯广告
//首页banner图
export const getIndexBannerListApi = data => get('/appletCbe/advert/getList/1', data);
//快捷入口
export const getIndexNavListApi = data => get('/appletCbe/advert/getList/2', data);
//品牌banner图
export const getBrandBannerListApi = data => get('/appletCbe/advert/getList/3', data);
//品牌置顶图
export const getBrandTopListApi = data => get('/appletCbe/advert/getList/4', data);
//品牌瀑布流
export const getBrandAdvertListApi = data => get('/appletCbe/advert/getList/5', data);
//工厂banner
export const getFactoryBannerListApi = data => get('/appletCbe/advert/getList/8', data);
//工厂置顶图
export const getFactoryAdvertListApi = data => get('/appletCbe/advert/getList/9', data);
//生态服务banner
export const getProviderBannerListApi = data => get('/appletCbe/advert/getList/6', data);
//生态服务置顶图
export const getProviderAdvertListApi = data => get('/appletCbe/advert/getList/7', data);
//产品banner图
export const getProductBannerListApi = data => get('/appletCbe/advert/getList/11', data);
//产品置顶图
export const getProductTopListApi = data => get('/appletCbe/advert/getList/12', data);
//产品广告图
export const getProductAdvertListApi = data => get('/appletCbe/advert/getList/13', data);
//开屏广告图
export const getLunchAdvertListApi = data => get('/appletCbe/advert/getList/14', data);
//直播广告图
export const getLiveBannerListApi = data => get('/appletCbe/advert/getList/15', data);
//资讯广告图
export const getNewsBannerListApi = data => get('/appletCbe/advert/getList/16', data);
//线上活动BANNER
export const getOnlineActivityBannerListApi = data => get('/appletCbe/advert/getList/17', data);
//线上活动置顶
export const getOnlineActivityTopListApi = data => get('/appletCbe/advert/getList/18', data);
//线上活动广告
export const getOnlineActivityAdvertListApi = data => get('/appletCbe/advert/getList/19', data);
//热门推荐BANNER
export const getHotRecBannerApi = data => get('/appletCbe/advert/getList/20', data);
//特备活动BANNER
export const getSpecialActivityApi = data => get('/appletCbe/advert/getList/21', data);
//小程序悬浮框
export const getSuspensionApi = data => get('/appletCbe/advert/getList/22', data);
//PC官网BANNER
export const getPcBannerApi = data => get('/appletCbe/advert/getList/23', data);
//PC官网顶部
export const getPcTopApi = data => get('/appletCbe/advert/getList/24', data);
//导览图推荐广告
export const getSiteGuideRecAdvertApi = data => get('/appletCbe/advert/getList/25', data);
//导览图置顶广告
export const getSiteGuideTopAdvertApi = data => get('/appletCbe/advert/getList/26', data);
//导览图BANNER
export const getSiteGuideBannerApi = data => get('/appletCbe/advert/getList/27', data);
//商家活动BANNER
export const getStoreActivityBannerApi = data => get('/appletCbe/advert/getList/28', data);
//展商名录BANNER
export const getExhibitionDictionnaryBannerApi = data => get('/appletCbe/advert/getList/29', data);
//首页精选日化商品
export const getJingxuanRihuaApi = data => get('/appletCbe/advert/getList/31', data);
//首页精选专业商品
export const getJingxuanExpertApi = data => get('/appletCbe/advert/getList/32', data);
//首页精选工厂商品
export const getJingxuanFactoryApi = data => get('/appletCbe/advert/getList/33', data);
//首页精选生态服务
export const getJingxuanProviderApi = data => get('/appletCbe/advert/getList/34', data);
//首页广告(左)
export const getIndexAdvertLeftApi = data => get('/appletCbe/advert/getList/35', data);
//首页广告(右)
export const getIndexAdvertRightApi = data => get('/appletCbe/advert/getList/36', data);
//首页广告(右)
export const getIndexAdvertRight2Api = data => get('/appletCbe/advert/getList/37', data);
//需求详情页广告
export const getDemandDetailAdvertApi = data => get('/appletCbe/advert/getList/46', data);
//每月新品页面BANNER
export const getMonthProductBannerApi = data => get('/appletCbe/advert/getList/48', data);

//获取unionID
export const getUnionIdApi = data => post('/info/getUnionId', data);
//用户信息
export const getCheckLoginApi = data => post('/info/checkCode', data);
//获取手机号
export const getWeixinPhoneApi = data => post('/info/getPhone', data);
//注册
export const registerApi = data => post('/info/register', data);
//token换用户信息
export const getUserInfoApi = data => get('/info/getUserInfo', data);
//token换用户信息  不存在就重新登录
export const getUserInfoNoLoginApi = data => noLogin('/info/getUserInfo', data);
//获取认证业务信息一二级联动信息
export const getNatureBusinessListApi = data => get('/info/getNatureBusinessList', data);
//获取职务列表
export const getPositionListApi = data => get('/info/getPositionList', data);
//提交认证
export const addAuthenticationApi = data => post('/info/addAuthentication', data);
//获取我的认证信息
export const getUserAuthenticationApi = data => get('/info/getUserAuthentication', data);
//更新我的认证信息
export const upDateAuthenticationApi = data => post('/info/upDateAuthentication', data);
//根据提交的认证的二级类型获取供需类型
export const getDemandStatusApi = data => post('/info/getDemandStatus', data);
//根据提交的认证的二级类型获取供需类型 新版
export const getDemandStatusOneApi = data => post('/info/getDemandStatusOne', data);
//找线下渠道 新版
export const getOfflineChannelApi = data => get('/info/getOfflineChannelNew', data);
//找线上渠道 新版
export const getOnlineChannelApi = data => get('/info/getOnlineDistributionNew', data);
//找品牌贸易商 新版
export const getBrandTradeApi = data => get('/info/getBrandTrade', data);
//找工厂的工厂类型列表 新版
export const getFactoryTypeListApi = data => post('/info/getFactory', data);
//找合作的类型列表 新版
export const getCooperationTypeListApi = data => get('/info/findCooperationType', data);
//找合作的找生态服务类型  新版
export const getServiceProviderTypeListApi = data => get('/info/getServiceProvider', data);
//找合作的找平台类型  新版
export const getPlateformProviderTypeListApi = data => get('/info/getPlatform', data);
//获取地域信息
export const getRegionListApi = data => get('/info/getRegionList', data);
//获取合作方规模
export const getScaleListApi = data => get('/info/getScaleList', data);
//获取需求详情
export const getDetailSupplyDemandByIdApi = data => post('/info/getDetailSupplyDemandById', data);
//（找线下零售） 请选择需求渠道  旧的
//export const getOfflineChannelApi = data => get('/info/getOfflineChannel', data);
//（找线上分销）请选择需求渠道
export const getOnlineDistributionApi = data => get('/info/getOnlineDistribution', data);
// 包装品类
export const getPackagingCategoryApi = data => get('/info/getPackagingCategory', data);
//获取需求日期
export const getDemandDateApi = data => get('/info/getDemandDate', data);
//提交供需
export const addSupplyDemandApi = data => post('/info/addSupplyDemand', data);
//我的供需列表
export const getMySupplyDemandListApi = data => noLoginPost('/info/getMySupplyDemandList', data);
//删除/下架我的供需
export const deleteMySupplyDemandApi = data => noLoginPost('/info/deleteMySupplyDemand', data);
//修改我的供需
export const updateSupplyDemandApi = data => noLoginPost('/info/updateSupplyDemand', data);
//我的供需详情
export const getDetailSupplyDemandApi = data => noLoginPost('/info/getDetailSupplyDemand', data);
//上下架供需
export const upperLowerShelvesApi = data => noLoginPost('/info/upperLowerShelves', data);

//搜索接口
//综合搜索
export const searchCompositeListApi = data => noLoginPost('/appletCbe/search/pageCompositeList', data);
//搜索品牌
export const searchBrandListApi = data => noLoginPost('/appletCbe/search/pageBrandList', data);
//搜索产品
export const searchProductListApi = data => noLoginPost('/appletCbe/search/pageProductList', data);
//搜索工厂
export const searchFactoryListApi = data => noLoginPost('/appletCbe/search/pageFactoryList', data);
//搜索生态服务
export const searchProviderListApi = data => noLoginPost('/appletCbe/search/pageProviderList', data);
//搜索供需
export const searchSupplyListApi = data => noLoginPost('/appletCbe/search/pageSupplyList', data);
//搜索热词
export const getHotWordsListApi = data => get('/appletCbe/search/getHotWords', data);


//精选/专题类型列表
export const getActivityColumnApi = data => get('/appletCbe/activity/getActivityColumn', data);

//根据活动id分页查询活动具体参与者列表
export const getActivityEntryListApi = data => noLoginPost('/appletCbe/activity/getEntryPageList', data);
//根据活动id获取产地列表
export const getActivityOriginListApi = data => iget('/appletCbe/activity/getOriginList', data);

//活动根据id查询详情
export const getActivityByIdApi = data => iget('/appletCbe/activity/getById', data);

//根据活动ID获取分类
export const getCategoryByActivityIdApi = data => iget('/appletCbe/activity/getCategory', data);

//首页-查询列表
export const getIndexListApi = data => post('/info/getSupplyDemandList', data);
//查看需求对接信息
export const getViewContactInformation = data => noLoginPost('/info/ViewContactInformation', data);

//展商名录
export const getExhibitorListApi = data => post('/appletCbe/company/pageExhibitorList', data);
//根据展商id获取品牌
export const getExhibitorBrandListApi = data => iget('/appletCbe/company/getBrandList', data);
//集团页面
export const getExhibitorByIdApi = data => iget('/appletCbe/company/getExhibitorById', data);
//集团页品牌列表
export const getGroupPageBrandListApi = data => post('/appletCbe/company/pageBrandList', data);

//新增贸易对接(提交发送消息)
export const addTradeDockingApi = data => post('/info/addTradeDocking', data);
//获取贸易对接留言选项
export const getTradeDockingSetApi = data => get('/info/tradeDockingSet', data);


//获得海报地址
//export const getPosterApi = data => iget('/appletCbe/poster/getPoster', data);
export const getPosterApi = data => noLoginPost('/appletCbe/poster/getPoster', data);

//收藏接口
//加入收藏
export const addMyCollectApi = data => noLoginPost('/appletCbe/myCollect/addMyCollect', data);
//收藏列表
export const myCollectListApi = data => noLoginPost('/appletCbe/myCollect/getPageList', data);
//加入收藏
export const deleteMyCollectApi = data => noLoginPost('/appletCbe/myCollect/delete', data);

//特邀活动列表
export const getBoutiqueActivitiesListApi = data => post('/info/getBoutiqueActivitiesList', data);
//特邀活动广告
export const getPageListAdvertApi = data => notoastpost('/info/getPageListAdvert', data);
//特邀活动报名的产品
export const getActivityRegistrationListAllApi = data => post('/info/getActivityRegistrationListAll', data);
//特邀活动报名的品牌
export const getActivityRegistrationBrandListApi = data => post('/info/getActivityRegistrationBrandList', data);
//特邀活动报名的展商
export const getActivityRegistrationCompanyListApi = data => post('/info/getActivityRegistrationCompanyList', data);

//访问记录
export const addVisitLogApi = data => post('/appletCbe/visitLog/add', data);

//直播预告
export const getBroadcastPlanApi = data => get('/appletCbe/broadcastPlan/getBroadcastPlan', data);
//直播列表
export const getBroadcastPlanPageListApi = data => post('/appletCbe/broadcastPlan/getPageList', data);

//我的消息
export const getMyTradeDockingListApi = data => post('/info/myTradeDockingList', data);
//消息设为已读
export const batchReadApi = data => post('/info/batchRead', data);
//我的未读消息数量
export const getMyTradeDockingCountApi = data => get('/info/myTradeDockingCount', data);
//调用小程序自带转发
export const sharePermissionAddApi = data => post('/appletCbe/sharePermission/add', data);

//资讯列表
export const getNewsPageListApi = data => post('/appletCbe/newsInfo/getPageList', data);
//资讯分类
export const getNewsColumnApi = data => get('/appletCbe/newsInfo/getNewsColumn', data);
//资讯详情
export const getNewsInfoByIdApi = data => post('/appletCbe/newsInfo/getById', data);


//支付api
export const paymentApi = data => post('/v1/wx/pay/doUnifiedOrder', data);


//省市区三级
export const getAddressCodeListApi = data => get('/info/getAddressCodeList', data);
//新增寄样
export const addApplySendSampleApi = data => post('/info/addApplySendSample', data);
//新增地址
export const addUserAddressApi = data => post('/info/addUserAddress', data);
//更新地址
export const updateUserAddressApi = data => post('/info/updateUserAddress', data);
//删除地址
export const deleteUserAddressApi = data => post('/info/deleteUserAddress', data);
//地址列表
export const getUserAddressListApi = data => get('/info/getUserAddressList', data);
//通过ID获取地址详情
export const getUserAddressByIdApi = data => post('/info/getUserAddressById', data);
//获取默认地址
export const getUserDefaultAddressApi = data => get('/info/getUserAddress', data);

//设置用户头像
export const setAvatarUrlApi = data => post('/info/setAvatarUrl', data);
//新版直播接口
export const getLiveListApi = data => post('/info/Applet/getLive', data);
//获取直播栏目
export const getLiveColumnApi = data => post('/info/Applet/getLiveColumn', data);
//直播回放接口
export const getPlayBackApi = data => post('/info/Applet/getPlayBack', data);
//直播埋点接口
export const setPointApi = data => post('/info/Applet/setPoint', data);
//申请寄样列表接口
export const myApplySendSampleApi = data => post('/info/myApplySendSample', data);
//我的申请寄样接口详情接口（同时设置为已读）
export const myApplySendSampleDetailApi = data => post('/info/myApplySendSampleDetail', data);
//首页产品列表
export const getHomePageProductListApi = data => post('/appletCbe/search/homePageProductList', data);


//记录需求对接按钮内的按钮点击记录
export const addButtonClickLogApi = data => post('/appletCbe/visitLog/addButton', data);
//非按钮级别访问记录
export const addVisitLogNewApi = data => post('/appletCbe/visitLog/addVisit', data);

//获取红人类型
export const getWiseManTypeApi = data => get('/appletCbe/wiseMan/getWiseManType', data);
//获取平台
export const getPlatformTypeApi = data => get('/appletCbe/wiseMan/getPlatformType', data);
//获取与红人的合作类型
export const getJointConsultTypeApi = data => get('/appletCbe/jointConsult/getType', data);
//新增合作咨询
export const addJointConsultApi = data => post('/appletCbe/jointConsult/add', data);
//MCN列表
export const getTalentOgrListApi = data => post('/info/Applet/talentOgrList', data);
//获取MCN类型
export const getOrgTypeListApi = data => get('/appletCbe/wiseMan/getOrgType', data);
//获取展商名录列表
export const getSceneRosterListApi = data => post('/appletCbe/sceneRoster/pageList', data);
//获取产品列表
export const getSceneRosterProductListApi = data => post('/appletCbe/sceneRoster/pageAllProducts', data);

//翻译接口
export const aliTranslateApi = data => post('/appletCbe/translate/aliTranslate', data);


export const getExhibitionBannerListApi = data => get('/appletCbe/advert/getList/29', data);
export const getbaseInfoListApi = data => get('/appletCbe/baseInfo/getList', data);
export const getPageAllProductsApi = data => post('/appletCbe/sceneRoster/pageAllProducts', data);
export const getBoothNumberListApi = data => post('/appletCbe/sceneRoster/getBoothNumberList', data);
export const getActivityListApi = data => post('/appletCbe/sceneRoster/getActivityList', data);
export const getAreaListApi = data => post('/appletCbe/sceneRoster/getProductAreaList', data);
export const getAllCategoryListApi = data => post('/appletCbe/sceneRoster/getProductCategoryByType', data);
export const getPageListApi = data => post('/appletCbe/sceneRoster/pageList', data);

export const getFactoryExhibitorById = data => iget('/appletCbe/company/getExhibitorById', data);
export const getPageProductListApi = data => post('/appletCbe/sceneRoster/pageProductList', data);
export const getEnExhibitorAdvertApi = data => get('/appletCbe/advert/getList/56', data);
export const getImageCodeApi = data => get('/appletCbe/email/imageCode', data);

export function sendListEmailApi(filePath, formData) {
	// console.log(formData.get('code'), 'formData.code')
	// console.log(formData.get('file'), 'formData.file')
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: BASEURL + '/appletCbe/email/sendListEmail',
			// method: 'post',
			filePath: filePath,
			name: 'file',
			header: {
				//'content-type': 'application/x-www-form-urlencoded',
				token: uni.getStorageSync('token')
			},
			formData,
			success: res => {
				if (res.statusCode == 200) {
					resolve(JSON.parse(res.data))
				} else {
					reject(res);
				}
			},
			fail: err => {
				reject(err);
			}
		})
	})


}



//上传图片
export const uploadPicApi = data => {
	//showLoading();
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: BASEURL + '/upload',
			filePath: data.file,
			name: 'file',
			header: {
				token: uni.getStorageSync('token'),
			},
			success: res => {
				if (res.statusCode == 200) {
					resolve(JSON.parse(res.data));
				} else if (res.statusCode == 600) {
					uni.redirectTo({
						url: '/pages/me/index'
					})
				} else {
					reject(res);
				}
			},
			fail: err => {
				reject(res);
			},
			complete: res => {
				reject(res);
			}
		})
	})
}